package cn.qicaiwang.open.app.controller;

import cn.qicaiwang.open.app.entity.LegalDocument;
import cn.qicaiwang.open.app.server.LegalDocumentService;
import cn.qicaiwang.open.common.response.ResponseResult;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * 法务模块
 */
@RestController
@RequestMapping("/qcwapp/LegalDocument")
public class APPLegalDocumentController {
    @Autowired
private LegalDocumentService legalDocumentService;


    /**
     * 根据一级分类获取二级分类
     */
    @GetMapping("/categories/level2")
    public ResponseResult<List<String>> getLevel2CategoriesByLevel1(
            @RequestParam String level1) {
        List<String> categories = legalDocumentService.getLevel2CategoriesByLevel1(level1);
        return ResponseResult.ok(categories);
    }

    /**
     * 根据二级分类获取三级分类
     */
    @GetMapping("/categories/level3")
    public ResponseResult<List<String>> getLevel3CategoriesByLevel2(
            @RequestParam String level2) {
        List<String> categories = legalDocumentService.getLevel3CategoriesByLevel2(level2);
        return ResponseResult.ok(categories);
    }

    /**
     * 根据三级分类获取具体的文档模板（分页）
     * @param page
     * @param level3
     * @return
     */
    @GetMapping("/categories/page")
    public ResponseResult<Page<LegalDocument>> getDocumentsByLevel3Page(
            Page<LegalDocument> page,
            @RequestParam String level3) {

        Page<LegalDocument> pageResult = legalDocumentService.getDocumentsByLevel3(page, level3);
        return ResponseResult.ok(pageResult);
    }

    /**
     * 普法动态
     * @return
     */
    @GetMapping("/dynamics")
    public ResponseResult getDynamics(){

        List<LegalDocument> result = legalDocumentService.getDynamics();
        return ResponseResult.ok(result);
    }
}
